package com.wpl.controller;

import com.wpl.bean.User;
import com.wpl.common.WebResponse;
import com.wpl.service.IOnlineService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/online")
public class OnlineController {

    @Resource
    private IOnlineService onlineService;

    /**
     * 获取在线人员
     * @return
     */
    @GetMapping("/users")
    public WebResponse getUsers(){
        List<User> users = onlineService.getUsers();
        if (!users.isEmpty()) {
            return WebResponse.success(users);
        }else {
            return WebResponse.failed();
        }
    }
}
